home *** CD-ROM | disk | FTP | other *** search
- Path: engnews1.Eng.Sun.COM!taumet!clamage
- From: bs@research.att.com
- Newsgroups: comp.std.c++
- Subject: Re: Observations on templates
- Date: 5 Feb 1996 23:30:07 GMT
- Organization: ?
- Approved: clamage@eng.sun.com (comp.std.c++)
- Message-ID: <199602052224.PAA26224@ncar.ucar.EDU>
- NNTP-Posting-Host: taumet.eng.sun.com
- Content-Type: text
- Content-Length: 2177
- X-Lines: 52
- Originator: clamage@taumet
-
- Article 15951 of comp.std.c++:
-
-
- John Max Skaller <maxtal@suphys.physics.su.oz.au> writes
-
- > Eugene Radchenko wrote:
- > > Why don't use, for instance, cast_d instead od
- > > dynamic_cast (ugh).
- >
- > This is quite deliberate. Bjarne dislikes casts. So do I.
- > He didn't invent new style casts (and RTTI) for your convenience,
- > he invented them to make sure no one else did.
-
- Hmmm. That is a bit strong. I find casts of all sorts overused.
- There is almost always a better way to write code than one that
- involves an explicit type conversion.
-
- However, IMO some casts are essential. Some uses of dynamic_cast are
- examples of code that cannot be written conveniently without help
- from the language; see D&E for examples. Please remember that you
- don't always have source code available so that you can modify classes
- to avoid the need for RTTI,and even where it is available you sometimes
- prefer not to touch it to minimize maintainance.
-
- > Long names were deliberately chosen to discourage use of casts.
-
- That, to make emphasize the seriousness of the operation done with
- a cast, and to make sure that casts are relatively easy to find in
- a program (``to make casts stand out like a sore thumb'').
-
- One think I have come to dislike about C-style casts is that they
- are almost invisible in code. Since they don't look like much,
- people get fooled into thinking they don't do much. Also, (T)e is a
- shorthand for several logically different operations (type conversion,
- reinterpretation of a bitpattern, casting away const, class hierarchy
- navigation) and you need to know the type T, the type of e, and the
- rules of C++ rather well to know which.
-
- - Bjarne
- [ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
- Contact address: std-c++-request@ncar.ucar.edu. The moderation policy is
- summarized in http://reality.sgi.com/employees/austern_mti/std-c++/policy.html
- ]
-